package year2021.month0234;

import java.util.concurrent.*;

public class ThreadTest {

    public static void main(String[] args){
        ExecutorService pool = new ThreadPoolExecutor(0, 8, 60L, TimeUnit.SECONDS,
                new LinkedBlockingDeque<>(1), Executors.defaultThreadFactory(), new ThreadPoolExecutor.AbortPolicy());
        for (int i=0; i<10; i++){
//            new Thread(new Print()).start();
            pool.execute(new Print());
        }
        pool.shutdown();
        System.out.println("================");
    }

}

class Print implements Runnable{
    public static int a;
    public final int b = a++;
    public final int max = 10;

    @Override
    public void run() {
        for (int i=0; i<max; i++){
//            System.out.print(b + " - " + i + " ;");
        }
        System.out.println(b);
    }
}